﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LiveSequence.Interface;
using LiveSequence.Suite.Interfaces;

namespace LiveSequence.Suite.Controls
{
  public class ToolStripCommandItem : ToolStripMenuItem
  {
    private ICommand _command;
    private object _target;

    public ToolStripCommandItem(ICommand command, object target)
    {
      _command = command;
      _target = target;

      Text = _command.Text(target);
      Visible = _command.IsVisible(target);
      Enabled = _command.CanExecute(target);

    }

    
    protected override void OnClick(EventArgs e)
    {
      base.OnClick(e);

      _command.Execute(_target);
    }
  }
}
